package club.menglinking.wechat.service.wechatservice;

import club.menglinking.wechat.entity.TextTypeEntity;
import club.menglinking.wechat.entity.enumbeen.NotFonudMsgBack;
import club.menglinking.wechat.util.BaseUtil;
import club.menglinking.wechat.util.XmlUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @ClassName TestServiceType
 * @Author Administrator
 * @Date 2018/12/30 15:35
 * @Version 1.0
 * @Description 处理文本类型的消息
 **/
@Service("textServiceType")
public class TextServiceType {
    private static final String MENU="功能";
    private static final String EVENT="subscribe";
    private static final String TOUDI="投递信息";

    public String handlealltext(Map stringMap){
        String toUserName = (String) stringMap.get("ToUserName");
        String fromUserName = (String) stringMap.get("FromUserName");
        String content = (String) stringMap.get("Content");
        String msgId = (String) stringMap.get("MsgId");
        String EventKey = (String)stringMap.get("EventKey");

        String newTime= BaseUtil.getBaseUtil().getIntegerTime();
        TextTypeEntity entity=new TextTypeEntity();
        entity.setToUserName(fromUserName);
        entity.setFromUserName(toUserName);
        entity.setCreatetime(newTime);
        entity.setMsgType("text");
        if (EVENT.equals(stringMap.get("Event"))){  //关注回复
            entity.setContent("等你很久了，欢迎关注最右段子精选。");
        }else if(MENU.equals(content)) {   //关键字回复
            entity.setContent("欢迎使用最右段子精选的菜单");
        }else if(TOUDI.equals(EventKey)){
            entity.setContent("投递信息暂不能使用");
        }else{                             //未匹配关键字回复
            entity.setContent(NotFonudMsgBack.getMsg(4));
        }
        return XmlUtil.getXmlUtil().ReturnMsg(entity);
    }
}
